home *** CD-ROM | disk | FTP | other *** search
- How IP bit masking works - G4POI July 13th 1993
-
- ========================================================================
- HOW ROUTING USING IP ADDRESS BIT MASKING WORKS
- ========================================================================
-
- Ever wondered how mail gets passed around the tcp/ip network and ends
- up in the right region at the right hub? (When it works that is!).
-
-
- WHAT AN IP ADDRESS REALLY IS:
- =============================
- A IP address is a four byte number. A byte is a number that can be anything
- between 0, and 255 in value. How does that work? Well a byte is made up
- of 8 binary bits, and a binary bit is a single digit that can only be
- a 0 or 1. Confusing isn't it?... Look at this;
-
-
- ONE BYTE
- ========
-
- 128 64 32 16 8 4 2 1 <-- what each "bit"
- represents
-
- 0 0 0 0 0 0 0 0 <-- binary "bits"
-
-
- Just follow this through and see how much sense it makes.
-
- When all of the binary "bits" are 0, then the total value of the byte is 0.
- Now lets change the value of some of the "bits" in our "byte".
-
- ______________________
- / \
- 0 0 0 0 0 1 0 1 |
- / |
- We have changed the right most "bit" to a 1 -' and also the 3rd from the
- right also to a 1. Look at the top diagram (ONE BYTE). The right most
- "bit" corresponds to the value 1, and the third from right hand "bit"
- corresponds to a value of 4. So the total value of our new byte, is
- 1 + 4 which equals 5 (good job I've got a calculator!).
-
-
- If we change the "bits" to this combination;
-
- 0 0 1 0 1 1 0 0
-
- thats; 0 + 0 + 32+ 0 + 8 + 4 + 0 + 0 = 44 Familiar?
-
-
- This is what an IP address of 44.131.19.160 looks like in binary;
- / / \ \
- _______/ / \ \__________
- / / \ \
- 00101100 10000011 00010011 10100000
-
-
- BIT MASKING:
- ============
- Now suppose we took that address (44.131.19.160) and only looked
- at the first 28 bits. Let's redraw the example and make it a bit more
- compressed so we can fit more information in.
-
-
- 44 . 131 . 19 . 160
- 00101100.10000011.00010011.10100000
- `-----------------------------'
- The first 28 bits
-
- And lets say that whatever happens, that these first 28 bits MUST be an
- exact match but the remaining 4 bits on the right can add up to any value
- and we aren't bothered about them. Lets see what that actually means.
-
- Just looking at the right most BYTE of the address, the 160 part of the
- address, if the left four bits always have to be 1010 (they do because
- they are included in the 28 bits which must be an exact match), then
- changing just the right hand four bits produces these numbers;
-
- 10100000 160
- 10100001 161
- 10100010 162
- 10100011 163
- 10100100 164
- . . and so on up
- . . until
- 10101111 175
-
- 175 is the highest number we can go up to without altering any of the
- four left hand bits. So if for instance G4HPE hub says in one of his
- configuration files (R_AIR.LST);
-
- route add 44.131.19.160/28 uhf g4poi
-
- It means that anything with an address of 44.131.19.160 to 44.131.19.175
- should be sent to station g4poi via his uhf interface. You can now
- see what the /28 means on the above address. i.e. the first 28 bits must
- match exactly but I don't care about the rest.
-
- If I said that the g4poi hub address is 160 and the next hub up is 176,
- then this will now make sense to you.... yes?!! Quite right! It's all
- to do with bit masking! And so will any changeover of addresses.
-
- Further reading: I recommend you read IP_PROP.TXT in /public/tcpip/news.
- It should now make far more sense as to why the addresses proposed
- are the values that they are.
-
-
- TOMORROW THE WORLD!:
- ====================
- I'm going to expand this explanation to show how (in theory at least),
- some mail could come all the way from the USA Internet network (thats the
- wire version of what we use) to sunny Northaw village ("on sea" if the polar
- caps melt and the tides in!). Please bare in mind that Internet uses
- domain names (that's the .ampr.org. type part of it) for much of the
- routing but this is after all just an imaginary example to make things
- clearer.
-
-
- Fred writes a message to say; "Hiya Dave. I've booked you a seat on
- concorde so you can pop in for lunch". (I wish!). And his system looks
- up g4poi.ampr.org and comes back with the ip address 44.131.19.160.
-
- His Internet "HUB" (equivalent of) has an entry in its routing table
- that looks like this;
-
- route add 44.0.0.0/8 modem k1ham
-
- Which routes any address with the first 8 bits matching the value of
- 44 exactly (amateur radio packet), down the modem line to a local ham
- station called k1ham.
-
- k1ham has the following entry in his routing table;
-
- route add 44.131.0.0/16 uksat g9ham
-
- Which routes any traffic for the United Kingdom (131) up on to satellite
- link to station g9ham who lives in England in the Stevenage area.
-
- g9ham has the following in his routing table;
-
- route add 44.131.19.0/24 uhf g4hpe
-
- Which routes all region 19 traffic to g4hpe.
-
- g4hpe (Steve), a real ham if ever there was one (hi!) has the following
- entry in his routing table;
-
- route add 44.131.19.160/28 uhf g4poi
-
- Which routes anything that has an address within the range of
- 44.131.19.160 to 44.131.19.175 to me (g4poi).
-
- I see the message arrive and read it. My reply would find its way back
- to fred in the states by a very similar process (carrier pigeon).
-
- So at each stage, "bit masking", i.e. only taking notice of certain "bits"
- of the address, is used to route the mail in ROUGHLY the right direction
- right down to the final stage where it arrives at its actual destination.
-
- And that, my friends, is how we do it at the moment!
-
- 73 de Dave g4poi@g4poi.ampr.org